package com.mjw.zstu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mjw.zstu.VO.ExhibitionCompanyVO;
import javafx.scene.control.Pagination;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public interface ExhibitionCompanyMapper extends BaseMapper<ExhibitionCompanyVO> {
    @Select("SELECT exhibition.* ,company.is_review as company_is_review," +
            "company.avatar_img,company.company_id,company.phone,company.emergency_contact,company.company_name," +
            "company.company_address FROM exhibition,company WHERE exhibition.company_id=company.company_id AND exhibition.id=#{id}")
    public Map getDetail(int id);
    @Select("SELECT exhibition.* ,company.is_review as company_is_review," +
            "company.avatar_img,company.company_id,company.emergency_people,company.phone,company.emergency_contact,company_name," +
            "company.company_address FROM exhibition,company WHERE exhibition.company_id=company.company_id order by exhibition.is_review LIMIT #{pageNum},#{pageSize}")
    public List<Map> getAllExhibition(int pageNum,int pageSize);
    @Select("SELECT COUNT(*) FROM exhibition,company WHERE exhibition.company_id=company.company_id ")
    public int allexhibition();
    @Select("SELECT\n" +
            "\texhibition.*,\n" +
            "\tcompany.is_review AS company_is_review,\n" +
            "\tcompany.avatar_img,\n" +
            "\tcompany.company_id,\n" +
            "\tcompany.emergency_people,\n" +
            "\tcompany.phone,\n" +
            "\tcompany.emergency_contact,\n" +
            "\tcompany_name,\n" +
            "\tcompany.company_address \n" +
            "FROM\n" +
            "\texhibition,\n" +
            "\tcompany \n" +
            "WHERE\n" +
            "\texhibition.is_review=1 AND exhibition.company_id = company.company_id \n" +
            "\tAND exhibition.type_id = #{type_id} \n" +"order by exhibition.end_time desc"+
            "\tLIMIT #{pageNum},#{pageSize}")
    public List<Map> getAllExhibitionbyType(int type_id,int pageNum,int pageSize);
    @Select("SELECT COUNT(*) FROM exhibition,company WHERE exhibition.is_review=1 AND exhibition.company_id=company.company_id AND exhibition.type_id=#{type_id}")
    public int allexhibitionbyType(int type_id);
    @Select("SELECT exhibition.* ,company.is_review as company_is_review," +
            "company.avatar_img,company.company_id,company.emergency_people,company.phone,company.emergency_contact,company_name," +
            "company.company_address FROM exhibition,company WHERE exhibition.is_review=1 and exhibition.company_id=company.company_id AND exhibition.type_id=#{type_id} LIMIT #{pageNum},#{pageSize}")
    public List<Map> getAllExhibitionbyCompany(String companyNname,int pageNum,int pageSize);
    @Select("SELECT COUNT(*) FROM exhibition,company WHERE exhibition.company_id=company.company_id AND company.company_name=#{companyName}")
    public int allexhibitionbyCompany(String companyName);
    @Select("SELECT exhibition.* ,company.is_review as company_is_review," +
            "company.avatar_img,company.company_id,company.emergency_people,company.phone,company.emergency_contact,company_name," +
            "company.company_address FROM exhibition,company WHERE exhibition.company_id=company.company_id AND #{end}>exhibition.start_time AND #{start}<exhibition.end_time and exhibition.is_review=1")
    public List<Map> getTodayExhibition(long start,long end);
}
